//
//  AddViewController.m
//  17_Work Contact
//
//  Created by dllo on 16/8/6.
//  Copyright © 2016年 yh. All rights reserved.
//

#import "AddViewController.h"

@interface AddViewController ()
@property (nonatomic, strong) UIImageView *picImageView;
@property (nonatomic, strong) UITextField *nameTextField;
@property (nonatomic, strong) UITextField *phoneNumTextField;
@property (nonatomic, strong) UITextField *addressTextField;

@property (nonatomic, strong) UIButton *addButton;
@end

@implementation AddViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationController.navigationBar.translucent = NO;
    [self createView];
}

- (void)createView {
    UILabel *nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(80, 240, 60, 30)];
    nameLabel.text = @"姓名";
    [self.view addSubview:nameLabel];
    UILabel *phoneLabel = [[UILabel alloc] initWithFrame:CGRectMake(80, 340, 60, 30)];
    phoneLabel.text = @"电话";
    [self.view addSubview:phoneLabel];
    UILabel *addressLabel = [[UILabel alloc] initWithFrame:CGRectMake(80, 290, 60, 30)];
    addressLabel.text = @"地址";
    [self.view addSubview:addressLabel];

    self.picImageView = [[UIImageView alloc] initWithFrame:CGRectMake(80, 10, 150, 200)];
    self.picImageView.backgroundColor = [UIColor redColor];
    [self.view addSubview:self.picImageView];
    
    self.nameTextField = [[UITextField alloc] initWithFrame:CGRectMake(160, 240, 200, 30)];
    [self.view addSubview:self.nameTextField];
    
    self.addressTextField = [[UITextField alloc] initWithFrame:CGRectMake(160, 290, 200, 30)];
    [self.view addSubview:self.addressTextField];
    
    self.phoneNumTextField = [[UITextField alloc] initWithFrame:CGRectMake(160, 340, 200, 30)];
    [self.view addSubview:self.phoneNumTextField];

    self.addButton = [UIButton buttonWithType:UIButtonTypeSystem];
    self.addButton.frame = CGRectMake(80, 390, 90, 30);
    [self.addButton setTitle:@"添加完成" forState:UIControlStateNormal];
    [self.view addSubview:self.addButton];
    [self.addButton addTarget:self action:@selector(addClick:) forControlEvents:UIControlEventTouchUpInside];
}

- (void)addClick:(UIButton *)button {
    self.contact = [[Contact alloc] initWithPicImage:@"u=3808451166,1723806820&fm=23&gp=0" name:self.nameTextField.text phoneNum:self.phoneNumTextField.text address:self.addressTextField.text];
    [self.delegate sendAddContact:self.contact];
    [self.navigationController popToRootViewControllerAnimated:YES];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
